package top.lixunda.ecommerce.server.user.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;
import top.lixunda.ecommerce.server.user.api.entity.dto.RegisterCodeDTO;

/**
 * @author Xumda
 * @version time:2019/12/14 12:25
 */
@Data
@EqualsAndHashCode
public class InsertUserDTO {

    private String username;

    private Integer type;

    private String password;

    private String nickname;

    public static InsertUserDTO fromRegisterCodeDTO(RegisterCodeDTO registerCodeDTO) {
        if (registerCodeDTO == null) {
            return null;
        }
        InsertUserDTO userDTO = new InsertUserDTO();
        userDTO.setUsername(registerCodeDTO.getUsername());
        userDTO.setPassword(registerCodeDTO.getPassword());
        userDTO.setType(registerCodeDTO.getType());
        userDTO.setNickname(registerCodeDTO.getNickname() == null ? "" : registerCodeDTO.getNickname());
        return userDTO;
    }

}
